// import { StudentService } from './modules/student/student.service2';
import { User } from './modules/user/models/user.entity';
import { Controller, Get } from '@nestjs/common';
import { UserService } from './modules/user/user.service';

@Controller()
export class AppController {
  constructor(
    private readonly userService: UserService,
    // private readonly studentService: StudentService
  ) {}

  // @Get('/hello')
  // async hello(): Promise<string> {
  //   return this.studentService.getHello();
  // }

  // 创建一个超级管理员
  @Get('/create')
  async create(): Promise<boolean> {
    return await this.userService.create({
      name: '水滴超级管理员',
      desc: '管理员',
      tel: '13083077845',
      code: '1234',
      codeCreateTimeAt: new Date()
    });
  }
  
  // 删除一个用户
  @Get('/delete')
  async delete(): Promise<boolean> {
    return await this.userService.del('admin');
  }

  // 更新一个用户
  @Get('/update')
  async update(): Promise<boolean> {
    return await this.userService.update('4d6b3163-85e1-4738-a294-8c707060ebb4', {
      name: '水滴用户1',
      desc: '用户',
      tel: '13083077845',
      code: '1234',
      codeCreateTimeAt: new Date()
    });
  }

  // 查询一个用户
  @Get('/find')
  async find(): Promise<User> {
    return await this.userService.find('4d6b3163-85e1-4738-a294-8c707060ebb4');
  }
}
